package com.lanou.musicbox.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;


import com.lanou.musicbox.R;
import com.lanou.musicbox.adapter.MyListViewAdapter;
import com.lanou.musicbox.base.BaseFragment;
import com.lanou.musicbox.bean.FindSongs;
import com.lanou.musicbox.bean.Mp3Info;

import java.util.List;

/**
 * Created by dllo on 15/10/20.
 */
public class LocalityFragment extends BaseFragment implements AdapterView.OnItemClickListener {
    public static final String UPDATE_UI = "com.aidl.music.updateui";
    private ListView locality_listview;
    private View view; //设置头布局
    private MyListViewAdapter adapter;
      private Button Finder;
    private List<Mp3Info> mp3Infos;
    private FindSongs findSongs;
    public MyListViewAdapter getAdapter() {
        return adapter;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.locality_listview, null);
        locality_listview = (ListView) view.findViewById(R.id.locality_listview);

       Finder= (Button) view.findViewById(R.id.Finder);
        findSongs = new FindSongs();
        mp3Infos = findSongs.getMp3Infos(getActivity().getContentResolver());
        Finder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Log.i("lan6666666", "onClick ");
                adapter = new MyListViewAdapter(getActivity().getApplicationContext(), mp3Infos);
                findSongs.setListAdpter(getActivity().getApplicationContext(), mp3Infos, locality_listview);
            }
        });

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        locality_listview.setOnItemClickListener(this);
    }
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


    }
}